package com.collection;

import java.lang.ref.WeakReference;

/**
 * 弱引用   垃圾回收及被回收
 *
 * @author jiangbang
 * @date 2016/5/31
 */
public class WeakReferenceDemo {

    public static void main(String[] args) {
        //字符串常量池
        String str = new String("very good");
        //弱引用管理对象
        WeakReference<String> wr = new WeakReference<String>(str);
        System.out.println("运行前："+wr.get());
        //断开引用
        str = null;
        //通知回收
        System.gc();
        System.runFinalization();
        System.out.println("运行后："+wr.get());
    }


}

